//
//  ViewController.m
//  transformDemo
//
//  Created by 李煜 on 2024/2/18.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic,strong) UIView * blueView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    UIView *blue = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    blue.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blue];
    self.blueView = blue;
}
- (IBAction)originalState {
    self.blueView.transform = CGAffineTransformIdentity;
}
- (IBAction)translationClick:(UIButton *)sender {
    [self originalState];
    self.blueView.transform = CGAffineTransformMakeTranslation(100, 0);
}
- (IBAction)rotationClick:(UIButton *)sender {
    [self originalState];
    self.blueView.transform = CGAffineTransformMakeScale(0.5, 0.5);

}
- (IBAction)scaleClick:(UIButton *)sender {
    [self originalState];

    self.blueView.transform = CGAffineTransformMakeScale(0.5, 0.2);
}

- (IBAction)multipleTranslations {    [self originalState];
    [self originalState];

    self.blueView.transform = CGAffineTransformTranslate(self.blueView.transform, 10, 0);
}
- (IBAction)multipleRotations {
    [self originalState];

    self.blueView.transform = CGAffineTransformRotate(self.blueView.transform, (M_PI_4));
}
- (IBAction)multipleScale {
    self.blueView.transform = CGAffineTransformScale(self.blueView.transform, 0.1, 0.1);
}
@end
